package com.tbit.uqbike.client.service.impl;

import com.tbit.uqbike.client.constant.MachineStateConstant;
import com.tbit.uqbike.client.dao.core.MachineFunctionDao;
import com.tbit.uqbike.client.pojo.MachineFunction;
import com.tbit.uqbike.client.service.MachineFunctionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 *
 *
 * @author <a href="mailto:chen.xiaoliang@tbit.com.cn">chen</a>
 * @version 1.0
 * @see <a href="#">订单号规范</a>
 * @since 2024/4/30
 */
@Service
public class MachineFunctionServiceImpl implements MachineFunctionService {

    @Autowired
    private MachineFunctionDao machineFunctionDao;

    @Override
    public Integer getValue(Integer machineId, Integer functionType) {
        Map<String, Object> map = new HashMap<>();
        map.put("machineId", machineId);
        map.put("functionType", MachineStateConstant.MACHINE_TYPE_NOPOINT);
        //兼容头盔锁功能
        MachineFunction machineFunctionDB = machineFunctionDao.getByMachineId(map);
        if(machineFunctionDB!=null){
            return machineFunctionDB.getFunctionValue();
        }
        return 0;
    }

    /**
     * @description: 获取车辆绑定的功能
     * @author: mo.shanyong
     * @date: 2025/4/11 10:44
     * @param: machineId 车辆id
     * @param: functionType 功能类型
     * @return: com.tbit.uqbike.client.pojo.MachineFunction
     */
    @Override
    public MachineFunction get(Integer machineId, Integer functionType) {
        Map<String, Object> map = new HashMap<>();
        map.put("machineId", machineId);
        map.put("functionType", functionType);
        //兼容头盔锁功能
        return machineFunctionDao.getByMachineId(map);
    }
}